package com.exercises;


public class Exercise165 {
    public static void main(String[] args) {
        System.out.println(compareVersion("0.1", "1.1"));
    }

    public static int compareVersion(String version1, String version2) {
        String[] a = version1.split("\\.");
        String[] b = version2.split("\\.");
        int min = Math.min(a.length, b.length);
        for (int i = 0; i < min; i++) {
            int div = Integer.parseInt(a[i]) - Integer.parseInt(b[i]);
            if (div > 0) return 1;
            if (div < 0) return -1;
        }
        if (a.length > b.length) {
            for (int i = min; i < a.length; i++) {
                if (Integer.parseInt(a[i]) != 0) return 1;
            }
        }

        if (a.length < b.length) {
            for (int i = min; i < b.length; i++) {
                if (Integer.parseInt(b[i]) != 0) return -1;
            }
        }

        return 0;
    }
}